#!/bin/sh

cp /app/ll /bin/ -arf

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/lib
export PATH=$PATH:/app/bin

export TZ=UTC-8:00

mkdir -p /factory/cfg /app/cfg;

#zerotier:
export PATH=$PATH:/app/zerotier;zerotier.sh &

#srt:
export PATH=$PATH:/app/srt;


#ircut-day:
sns=$(echo $(grep "sensor" /factory/cfg/bsp_def.json) | sed -e "s/\"//g" -e "s/sensor://g" | cut -d ',' -f 1 | cut -d '[' -f 2)
echo "sensor is $sns"
if [ $sns == "imx334" ] ; then
    echo 1 > /sys/class/gpio/gpio27/value;echo 1 > /sys/class/gpio/gpio28/value;
else
    echo 1 > /sys/class/gpio/gpio27/value;echo 0 > /sys/class/gpio/gpio28/value;sleep 0.1;echo 0 > /sys/class/gpio/gpio27/value
fi

bsp.exe    /factory/cfg/bsp_def.json /app/cfg/bsp_parm.json & 
codec.exe  /app/cfg/codec_parm.json  &
rec.exe    /app/cfg/rec_parm.json  &
rtsps.exe  /app/cfg/rtsps_parm.json  &
rtmps.exe  /app/cfg/rtmps_parm.json &
onvif.exe  /app/cfg/onvif_parm.json  &
webs.exe   /app/cfg/webs_parm.json &
svp.exe    /app/cfg/svp_parm.json &
app.exe    /app/cfg/app_parm.json &
sips.exe    /app/cfg/sips_parm.json &
srts.exe    /app/cfg/srts_parm.json &

sleep 5;
if [ $sns == "bt1120" ] ; then
    /app/check_audio_sw.sh &
fi
